{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    {include file='public:left-menu'/}
    <!--End 左侧导航-->
    <!--头部信息-->
    {include file='public:nav-header' title="会员管理" subTitle="添加编辑等级"/}
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content" id="app">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
                <form method="post" id="submit-form" class="edit-form">
                    <div class="card-header form-header"><h4>等级相关设置</h4></div>
                    <div class="form-info">
                        <div class="form-group row">
                            <div class="col-md-12">
                                <label class="form-title"><em class="require">*</em>等级名称</label>
                                <input type="text" class="form-control" name="name" value="{$level.name}" placeholder="请输入等级名称"/>
                                <span class="help">等级必要名称</span>
                                <span class="error" id="err_name"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-info">
                        <div class="form-group row">
                            <div class="col-md-3">
                                <label class="form-title"><em class="require">*</em>加权奖励比例</label>
                                <input type="text" class="form-control" name="jq_jl_bili" value="{$level.jq_jl_bili}" placeholder="请输入加权奖励比例"/>
                                <span class="error" id="err_jq_jl_bili"></span>
                            </div>
                            <div class="col-md-3">
                                <label class="form-title"><em class="require">*</em>团队分红奖励比例</label>
                                <input type="text" class="form-control" name="jl_bili" value="{$level.jl_bili}" placeholder="请输入团队分红奖励比例"/>
                                <span class="error" id="err_jl_bili"></span>
                            </div>
                            <div class="col-md-3">
                                <label class="form-title"><em class="require">*</em>储备金释放比例</label>
                                <input type="text" class="form-control" name="cbj_sf_bl" value="{$level.cbj_sf_bl}" placeholder="请输入储备金释放比例"/>
                                <span class="error" id="err_cbj_sf_bl"></span>
                            </div>
                            <div class="col-md-3">
                                <label class="form-title"><em class="require">*</em>平级奖励比例</label>
                                <input type="text" class="form-control" name="pj_jl" value="{$level.pj_jl}" placeholder="请输入平级奖励比例"/>
                                <span class="error" id="err_pj_jl"></span>
                            </div>
                        </div>
                    </div>
                    <div class="card-header form-header"><h4>升级相关设置</h4></div>
                    <div class="form-info">
                        <div class="form-group row">
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>累计认养金额</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.lj_ry_open==1}">
                                            <input type="radio" name="lj_ry_open" value="1" v-model="level.lj_ry_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.lj_ry_open==0}">
                                            <input type="radio" name="lj_ry_open" value="0" v-model="level.lj_ry_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.lj_ry_open==0" name="lj_ry_yeji" value="{$level.lj_ry_yeji}" placeholder="请输入累计认养金额"/>
                                <span class="help">所需累计认养金额</span>
                                <span class="error" id="err_lj_ry_yeji"></span>
                            </div>
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>团队认养业绩</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.td_ry_yeji_open==1}">
                                            <input type="radio" name="td_ry_yeji_open" value="1" v-model="level.td_ry_yeji_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.td_ry_yeji_open==0}">
                                            <input type="radio" name="td_ry_yeji_open" value="0" v-model="level.td_ry_yeji_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.td_ry_yeji_open==0" name="td_ry_yeji" value="{$level.td_ry_yeji}" placeholder="请输入团队认养业绩"/>
                                <span class="help">所需团队认养业绩</span>
                                <span class="error" id="err_td_ry_yeji"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>大市场认养业绩</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.dsc_ry_yeji_open==1}">
                                            <input type="radio" name="dsc_ry_yeji_open" value="1" v-model="level.dsc_ry_yeji_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.dsc_ry_yeji_open==0}">
                                            <input type="radio" name="dsc_ry_yeji_open" value="0" v-model="level.dsc_ry_yeji_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.dsc_ry_yeji_open==0" name="dsc_ry_yeji" value="{$level.dsc_ry_yeji}" placeholder="请输入团队认养业绩"/>
                                <span class="help">所需大市场认养业绩</span>
                                <span class="error" id="err_dsc_ry_yeji"></span>
                            </div>
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>升级条件</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.update_open==1}">
                                            <input type="radio" name="update_open" value="1" v-model="level.update_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.update_open==0}">
                                            <input type="radio" name="update_open" value="0" v-model="level.update_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <div class="control">
                                    <input type="number" class="form-control" :readonly="level.update_open==0" name="market_num" value="{$level.market_num}" placeholder="请输入市场"/>
                                    <span>&nbsp;个市场&nbsp;每个市场需&nbsp;</span>
                                    <input type="number" class="form-control" :readonly="level.update_open==0" name="num" value="{$level.num}" placeholder="请输入人数"/>
                                    <span v-if="level.update_open==1">&nbsp;名&nbsp;</span>
                                    <select class="input-group-select" name="num_level_id" v-show="level.update_open==1">
                                        <option value="">无</option>
                                        {volist name="$level_list" id="level1"}
                                        <option value="{$level1.level_id}" {if $level.num_level_id==$level1.level_id}selected{/if}>{$level1.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <span class="error" id="err_market_num"></span>
                                <span class="error" id="err_num"></span>
                                <span class="error" id="err_num_level_id"></span>
                            </div>
                        </div>
                    </div>
                    <div class="card-header form-header"><h4>团队分红相关设置</h4></div>
                    <div class="form-info">
                        <div class="form-group row">
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>累计认养金额</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.fh_lj_ry_open==1}">
                                            <input type="radio" name="fh_lj_ry_open" value="1" v-model="level.fh_lj_ry_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.fh_lj_ry_open==0}">
                                            <input type="radio" name="fh_lj_ry_open" value="0" v-model="level.fh_lj_ry_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.fh_lj_ry_open==0" name="fh_lj_ry_yeji" value="{$level.fh_lj_ry_yeji}" placeholder="请输入累计认养金额"/>
                                <span class="help">所需累计认养金额</span>
                                <span class="error" id="err_fh_lj_ry_yeji"></span>
                            </div>
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>团队认养业绩</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.fh_td_ry_yeji_open==1}">
                                            <input type="radio" name="fh_td_ry_yeji_open" value="1" v-model="level.fh_td_ry_yeji_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.fh_td_ry_yeji_open==0}">
                                            <input type="radio" name="fh_td_ry_yeji_open" value="0" v-model="level.fh_td_ry_yeji_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.fh_td_ry_yeji_open==0" name="fh_td_ry_yeji" value="{$level.fh_td_ry_yeji}" placeholder="请输入团队认养业绩"/>
                                <span class="help">所需团队认养业绩</span>
                                <span class="error" id="err_fh_td_ry_yeji"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>大市场认养业绩</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.fh_dsc_ry_yeji_open==1}">
                                            <input type="radio" name="fh_dsc_ry_yeji_open" value="1" v-model="level.fh_dsc_ry_yeji_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.fh_dsc_ry_yeji_open==0}">
                                            <input type="radio" name="fh_dsc_ry_yeji_open" value="0" v-model="level.fh_dsc_ry_yeji_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <input type="text" class="form-control" :readonly="level.fh_dsc_ry_yeji_open==0" name="fh_dsc_ry_yeji" value="{$level.fh_dsc_ry_yeji}" placeholder="请输入团队认养业绩"/>
                                <span class="help">所需大市场认养业绩</span>
                                <span class="error" id="err_fh_dsc_ry_yeji"></span>
                            </div>
                            <div class="col-md-6">
                                <label class="form-title form-title-vue">
                                    <em class="require">*</em>
                                    <span>分红条件</span>
                                    <div class="btn-group form-group-toggle-vue">
                                        <label class="radio-btn radio-theme" :class="{'active':level.fh_update_open==1}">
                                            <input type="radio" name="fh_update_open" value="1" v-model="level.fh_update_open">
                                            <i class="mdi mdi-checkbox-marked-circle-outline"> 开启</i>
                                        </label>
                                        <label class="radio-btn radio-default" :class="{'active':level.fh_update_open==0}">
                                            <input type="radio" name="fh_update_open" value="0" v-model="level.fh_update_open">
                                            <i class="mdi mdi-close-circle-outline"> 关闭</i> </label>
                                    </div>
                                </label>
                                <div class="control">
                                    <input type="number" class="form-control" :readonly="level.fh_update_open==0" name="fh_market_num" value="{$level.fh_market_num}" placeholder="请输入市场"/>
                                    <span>&nbsp;个市场&nbsp;每个市场需&nbsp;</span>
                                    <input type="number" class="form-control" :readonly="level.fh_update_open==0" name="fh_num" value="{$level.fh_num}" placeholder="请输入人数"/>
                                    <span v-if="level.fh_update_open==1">&nbsp;名&nbsp;</span>
                                    <select class="input-group-select" name="fh_num_level_id" v-show="level.fh_update_open==1">
                                        <option value="">无</option>
                                        {volist name="$level_list" id="level1"}
                                        <option value="{$level1.level_id}" {if $level.fh_num_level_id==$level1.level_id}selected{/if}>{$level1.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <span class="error" id="err_fh_market_num"></span>
                                <span class="error" id="err_fh_num"></span>
                                <span class="error" id="err_fh_num_level_id"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-info">
                        <div class="form-group" style="margin-bottom: 15px">
                            <input type="hidden" name="{$level.pk}" value="{$level[$level.pk]}">
                            <button type="button" class="btn-theme submit-btn">确定</button>
                        </div>
                    </div>
                </form>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<style>
    .control{
        display: flex;
        align-items: center;
        min-height: 38px;
    }
    .control input{
        border:1px solid #ebebeb;
        border-radius: 2px;
        width: 200px;
        height: 38px;
    }
    .form-info{
        padding: 10px 24px;
    }
    .form-info .form-group{
        margin-bottom: 0;
    }
    .form-title-vue .form-group-toggle-vue{
        margin-left: 10px;
        padding: 10px 0;
    }
</style>
<script type="text/javascript">
    var _this;
    var app = new Vue({
        el: '#app',
        data: {
            level: JSON.parse('{:json_encode($level)}')|| [],
        },
        created() {
            _this=this
        },
        methods: {
        },
        mounted(){

        }
    });
  $(function(){
    $('.submit-btn').click(function () {
      $('span.error').hide();
      $('span.error').parent().removeClass('has-error');
      var url = "{:url('User/add_edit_level')}";
      var data = $('#submit-form').serialize();
      $.ajax({
        type: "POST",
        url: url,
        data: data,
        dataType: 'json',
        success: function (data) {
          if (data.code == 1) {
            showSuccessMsg(data.msg, function () {
              if (data.data.url) {
                location.href = data.data.url;
              }
            });
          } else if (data.code == 10) {
              showErrorMsg(data.msg);
            $.each(data.data.result, function(index, item) {
              $('#err_' + index).text(item).show();
              $('#err_' + index).parent().addClass('has-error');
            });
          } else {
            showErrorMsg(data.msg);
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            showErrorMsg("网络失败，请刷新后重试!");
        }
      });
    });
  });
  function call_back(fileurl_tmp,fileurl_id)
  {
    $("[name="+fileurl_id+"]").val(fileurl_tmp);
    $("#"+fileurl_id).attr('src', fileurl_tmp);
  }
</script>
</body>
</html>
